//
//  HeaderView.m
//  KeleAppProject
//
//  Created by 周岑 on 2018/1/12.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "HeaderView.h"

@interface HeaderView()


@end

@implementation HeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = KLColor_C1;
        [self loadSubviewOnHeader];
    }
    return self;
}

// 加载视图
- (void)loadSubviewOnHeader{
    
    UIView *bgView = [[UIView alloc]init];
    bgView.backgroundColor = [UIColor whiteColor];
    [self addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.bottom.equalTo(self).offset(-10*HEIGHT);
    }];
    
    UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [loginBtn setTitle:@"登录" forState:UIControlStateNormal];
    [loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    loginBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16*WIDTH];
    loginBtn.backgroundColor = KLColor_A1;
    [bgView addSubview:loginBtn];
    self.loginButton = loginBtn;
    [loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self).offset(49*HEIGHT);
        make.width.mas_equalTo(102*WIDTH);
        make.height.mas_equalTo(34*HEIGHT);
    }];
    
    UILabel *collecLB = [[UILabel alloc]init];
    collecLB.text = @"收藏";
    collecLB.textColor = KLColor_B4;
    collecLB.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13*WIDTH];
    [bgView addSubview:collecLB];
    [collecLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(bgView).offset(-38*HEIGHT);
        make.left.equalTo(bgView).offset(42.5*WIDTH);
    }];
    
    UILabel *collecNumLB = [[UILabel alloc]init];
    collecNumLB.text = @"0";
    collecNumLB.textColor = KLColor_B4;
    collecNumLB.font = [UIFont fontWithName:@"PingFangSC-Medium" size:16*WIDTH];
    [bgView addSubview:collecNumLB];
    [collecNumLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(collecLB);
        make.top.equalTo(collecLB.mas_bottom).offset(1);
    }];
    
    UILabel *playLB = [[UILabel alloc]init];
    playLB.text = @"播放";
    playLB.textColor = KLColor_B4;
    playLB.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13*WIDTH];
    [bgView addSubview:playLB];
    [playLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(collecLB);
        make.left.equalTo(collecLB.mas_right).offset(61*WIDTH);
    }];
    
    UILabel *playNumLB = [[UILabel alloc]init];
    playNumLB.text = @"156";
    playNumLB.textColor = KLColor_B4;
    playNumLB.font = [UIFont fontWithName:@"PingFangSC-Medium" size:16*WIDTH];
    [bgView addSubview:playNumLB];
    [playNumLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(playLB);
        make.top.equalTo(playLB.mas_bottom).offset(1);
    }];
    
    UILabel *containLB = [[UILabel alloc]init];
    containLB.text = @"关注";
    containLB.textColor = KLColor_B4;
    containLB.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13*WIDTH];
    [bgView addSubview:containLB];
    [containLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(collecLB);
        make.left.equalTo(playLB.mas_right).offset(61*WIDTH);
    }];
    
    UILabel *containNumLB = [[UILabel alloc]init];
    containNumLB.text = @"0";
    containNumLB.textColor = KLColor_B4;
    containNumLB.font = [UIFont fontWithName:@"PingFangSC-Medium" size:16*WIDTH];
    [bgView addSubview:containNumLB];
    [containNumLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(containLB);
        make.top.equalTo(containLB.mas_bottom).offset(1);
    }];
    
    UILabel *fansLB = [[UILabel alloc]init];
    fansLB.text = @"粉丝";
    fansLB.textColor = KLColor_B4;
    fansLB.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13*WIDTH];
    [bgView addSubview:fansLB];
    [fansLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(collecLB);
        make.left.equalTo(containLB.mas_right).offset(61*WIDTH);
    }];
    
    UILabel *fansNumLB = [[UILabel alloc]init];
    fansNumLB.text = @"0";
    fansNumLB.textColor = KLColor_B4;
    fansNumLB.font = [UIFont fontWithName:@"PingFangSC-Medium" size:16*WIDTH];
    [bgView addSubview:fansNumLB];
    [fansNumLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(fansLB);
        make.top.equalTo(fansLB.mas_bottom).offset(1);
    }];
    
    
    
}


// 圆角
- (void)layoutSublayersOfLayer:(CALayer *)layer{
    [super layoutSublayersOfLayer:layer];
    [self.loginButton layoutIfNeeded];
    [self.loginButton setRadiusWithValue:4*HEIGHT];
}

@end
